<?php

class PortfolioController extends Site_Controller_Action
{
    public function init()
    {
        $this->body_class = 'left-sidebar';
    }

    public function indexAction()
    {
        $result = $this->db->fetchAll('SELECT SQL_CACHE * FROM ST_PORTFOLIO WHERE POR_STA = 1 ORDER BY POR_DAT DESC');
        $this->view->portfolios = $result; 

        $id = $this->_getParam('id', 0);
        if($id > 0){
            $result = $this->db->fetchRow('SELECT SQL_CACHE * FROM ST_PORTFOLIO WHERE POR_ID = '.$id.' AND POR_STA = 1');
            $this->view->portfolio = $result; 
        } else {
            $result = $this->db->fetchRow('SELECT SQL_CACHE * FROM ST_PORTFOLIO WHERE POR_STA = 1 ORDER BY POR_ID DESC');
            $this->view->portfolio = $result; 
        }
    }
    
}

